package com.ruoyi.edit.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.edit.domain.TcVendorCourseUserRecord;
import com.ruoyi.edit.service.ITcVendorCourseUserRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程修改记录Controller
 * 
 * @author qiufeng
 * @date 2022-12-05
 */
@Controller
@RequestMapping("/system/vendorCourseUserRecord")
public class TcVendorCourseUserRecordController extends BaseController
{
    private String prefix = "system/vendorCourseUserRecord";

    @Autowired
    private ITcVendorCourseUserRecordService tcVendorCourseUserRecordService;

    @GetMapping()
    public String vendorCourseUserRecord(String vendorCourseId, ModelMap mmap)
    {
        mmap.put("vendorCourseId", vendorCourseId);
        return prefix + "/vendorCourseUserRecord";
    }


    /**
     * 查询课程修改记录列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TcVendorCourseUserRecord tcVendorCourseUserRecord)
    {
        startPage();
        List<TcVendorCourseUserRecord> list = tcVendorCourseUserRecordService.selectTcVendorCourseUserRecordList(tcVendorCourseUserRecord);
        return getDataTable(list);
    }

    /**
     * 导出课程修改记录列表
     */
    @Log(title = "课程修改记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TcVendorCourseUserRecord tcVendorCourseUserRecord)
    {
        List<TcVendorCourseUserRecord> list = tcVendorCourseUserRecordService.selectTcVendorCourseUserRecordList(tcVendorCourseUserRecord);
        ExcelUtil<TcVendorCourseUserRecord> util = new ExcelUtil<TcVendorCourseUserRecord>(TcVendorCourseUserRecord.class);
        return util.exportExcel(list, "课程修改记录数据");
    }

    /**
     * 新增课程修改记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存课程修改记录
     */
    @Log(title = "课程修改记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TcVendorCourseUserRecord tcVendorCourseUserRecord)
    {
        return toAjax(tcVendorCourseUserRecordService.insertTcVendorCourseUserRecord(tcVendorCourseUserRecord));
    }

    /**
     * 修改课程修改记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TcVendorCourseUserRecord tcVendorCourseUserRecord = tcVendorCourseUserRecordService.selectTcVendorCourseUserRecordById(id);
        mmap.put("tcVendorCourseUserRecord", tcVendorCourseUserRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存课程修改记录
     */
    @Log(title = "课程修改记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TcVendorCourseUserRecord tcVendorCourseUserRecord)
    {
        return toAjax(tcVendorCourseUserRecordService.updateTcVendorCourseUserRecord(tcVendorCourseUserRecord));
    }

    /**
     * 删除课程修改记录
     */
    @Log(title = "课程修改记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tcVendorCourseUserRecordService.deleteTcVendorCourseUserRecordByIds(ids));
    }
}
